<?php 



	if(!isset($_SESSION['username'])){
		echo "<script>alert('请登录！');window.location.href='index.php?m=admin&c=manage'</script>";die;
	}



	authonity($con);




	$mid = $_GET['mid'];

	$aid = $_GET['aid'];
//提交
	if($_POST){
//		var_dump($_POST) ; die;
	
		
			$con = connect('localhost','root','','login');
			//获取数据
		
			
			// $data['edit'] = htmlspecialchars(trim($_POST['edit']))
			$data['create_time'] = time();
			$data['cate_id'] = $_POST['category_id'];



			//图片上传
			if(isset($_FILES['banner'])){
				$pro_img = $_FILES['banner'];
				$img = uploadsIMG($pro_img);

				$ho_thumb = retio_thumb($img,500);
				$ad_thumb = retio_thumb($img,100);


				$img_path[] = $img;
				$img_path[] = $ho_thumb;
				$img_path[] = $ad_thumb;
				$data['path'] = json_encode($img_path);

			}

			$data['status'] = $_POST{'status'};

			
			


			
			$query = dbinsert($con,'banner',$data);
			if($query){
				echo "<script>alert('添加成功');window.location.href = 'index.php?m=admin&c=banner&mid=31&aid=$aid'</script>";
			}else{
				echo "<script>alert('添加失败');window.location.href = 'index.php?m=admin&c=banner&v=ban_insert&mid=$mid&aid=$aid'</script>";
			}
}	//添加
	




	$cate = dbselect($con,'category','category_name,id','pid=0');	


	assign('cate',$cate);














?>